<?php
//
//	file: includes/aucp/color_plug_privmsg.php
//	begin: 30/04/2007
//	$Author: christopher $
//	$Revision: 29 $
//	$Date: 2008-07-19 15:59:35 +0000 (Sat, 19 Jul 2008) $
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	description: color plugs for privmsg

if (!defined('IN_PHPBB'))
{
	die("Hacking attempt");
}

class color_privmsg extends plug_ins
{
	function display_message ($privmsg, $privmsgs_id)
	{
		global $colors, $db, $username_from, $username_to, $user_id_from, $user_id_to;

		$sql = "SELECT u.user_group_id AS user_group_id_1, u2.user_group_id AS user_group_id_2, u.user_session_time AS user_session_time_1, u2.user_session_time AS user_session_time_2
			FROM " . USERS_TABLE . " u, " . USERS_TABLE . " u2
			WHERE u.user_id = $user_id_from
				AND u2.user_id = $user_id_to";
		$result = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result);

		$username_from = $colors->get_user_color($row['user_group_id_1'], $row['user_session_time_1'], $username_from);
		$username_to = $colors->get_user_color($row['user_group_id_2'], $row['user_session_time_2'], $username_to);

		return;
	}

	function preview()
	{
		global $colors, $db, $user, $template, $to_username;

		// let's play with the template info
		$sql = "SELECT username, user_group_id, user_session_time
			FROM " . USERS_TABLE . "
			WHERE username = '" . str_replace("\'", "''", $to_username) . "'
				AND user_id <> " . ANONYMOUS;
		$result = $db->sql_query($sql, false, __LINE__, __FILE__, true);
		$row = $db->sql_fetchrow($result);

		$template->assign_vars(array(
			'S_TO' => $colors->get_user_color($row['user_group_id'], $row['user_session_time']),
			'S_FROM' => $colors->get_user_color($user->data['user_group_id'], $user->data['user_session_time']),
		));

		return;
	}

	function display_row ($row)
	{
		global $colors, $template;

		// let's play with the template info
		$template->assign_lastblock_vars('listrow', array(
			'FROM' => $row['username'],
			'S_FROM' => $colors->get_user_color($row['user_group_id'], $row['user_session_time']),
		));

		return;
	}
}

?>